using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Rocuna.Graphics.Core;

namespace Rocuna.Graphics
{
    /// <summary>
    /// Manager class to manage the graphic output.
    /// </summary>
    public class GraphicManager
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicManager"/> class.
        /// </summary>
        public GraphicManager(Game game)
        {
            GraphicsDevice = game.GraphicsDevice;
            Cameras = new Dictionary<string, Camera>();
        }

        #region Private fields

        /// <summary>
        /// Gets or sets the current camera.
        /// </summary>
        /// <value>
        /// The current camera.
        /// </value>
        public Camera CurrentCamera { get; set; }

        /// <summary>
        /// Gets or sets the cameras.
        /// </summary>
        /// <value>
        /// The cameras.
        /// </value>
        public Dictionary<string, Camera> Cameras { get; set; }

        /// <summary>
        /// This GraphicManager Graphic device.
        /// </summary>
        protected GraphicsDevice GraphicsDevice;

        #endregion

        #region Public methods

        /// <summary>
        /// Loads the content.
        /// </summary>
        public void LoadContent()
        {
        }

        /// <summary>
        /// Draw according to the specified game time.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        public void Draw(GameTime gameTime)
        {
        }

        /// <summary>
        /// Registers the camera.
        /// </summary>
        /// <param name="cameraToRegister">The camera to register.</param>
        public void RegisterCamera(Camera cameraToRegister)
        {
            Cameras.Add(cameraToRegister.Name, cameraToRegister);
        }

        /// <summary>
        /// Unregisters the camera.
        /// </summary>
        /// <param name="cameraToRemove">The camera to remove.</param>
        public void UnregisterCamera(Camera cameraToRemove)
        {
            Cameras.Remove(cameraToRemove.Name);
        }

        /// <summary>
        /// Activates the camera.
        /// </summary>
        /// <param name="cameraName">Name of the camera.</param>
        public void ActivateCamera(string cameraName)
        {
            if (CurrentCamera != null)
                CurrentCamera.Deactivate();
            CurrentCamera = Cameras[cameraName];
            CurrentCamera.Activate();
        }

        #endregion
    }
}